<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
﻿<!DOCTYPE HTML>
<html>
<head>
<jsp:include page="common_header.jsp" flush="true"></jsp:include>
<title>设备信息列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 设备信息管理 <span class="c-gray en">&gt;</span> 设备信息列表 <a id="refreshBtn" class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c"> 创建时间：
		<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
		<input type="text" class="input-text" style="width:250px" placeholder="输入关键字" id="keywords" name="">
		<button type="button" onclick="queryDataList()" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜设备信息</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="batchDel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" onclick="equipment_add('添加设备信息','${path}/user/toPage.do?page=equipment-add','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加设备信息</a></span> <span class="r">共有数据：<strong id="totalRow">-</strong> 条</span> </div>
	<table id="equipmentTbl" class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">设备信息列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value="" onclick="checkAll(this)"/></th>
				<th width="30">序号</th>
				<th width="80">设备编号</th>
				<th width="80">设备名称</th>
				<th width="80">设备数量</th>
				<th width="80">设备描述</th>
				<th width="80">采购时间</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>
<jsp:include page="_footer.jsp" flush="true"></jsp:include>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${path }/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript">

$(function(){
	
	initDg('equipmentTbl', {
		queryUrl : '${path}/equipment/query.do',
		methodType: 'get',
		beforeAjax : function(data){
			data.begin = $('#datemin').val();
        	data.end = $('#datemax').val();
        	data.keywords = $('#keywords').val();
		},
		sucessAjax : function(result){
			$('#totalRow').html(result.data.recordsTotal);
		},
		columns: [
            { "data": null },
            { "data": null },
            { "data": "no" },
            { "data": "name" },
            { "data": "num" },
            { "data": "desp" },
            { "data": "perchaseTime" },
            { "data": null }
        ],
        rowCallback : function(row, data, index){
        	$('td:eq(6)', row).html( fmtMillsec(data.perchaseTime, true) );
    		$('td:eq(7)', row).addClass('td-manage');
    		$('td:eq(7)', row).html( '<a title="编辑" href="javascript:;" onclick="equipment_edit(\'设备信息编辑\',\'${path}/user/toPage.do?page=equipment-add\','+data.id+',\'800\',\'500\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="equipment_del(this,'+data.id+')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>' );
        }
	});
	
});


function refresh(index){
	queryDataList();
	layer.close(index);
}

function queryDataList(){
	$("#equipmentTbl").dataTable().fnDraw(false);
}


/*设备信息-增加*/
function equipment_add(title,url,w,h){
	layer_show(title,url,w,h);
}

/*设备信息-删除*/
function equipment_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		jajax({
			type: 'POST',
			url: '${path}/equipment/delete.do',
			data: 'ids='+id,
			success: function(data){
				layer.msg('已删除!',{icon:1,time:1000});
				queryDataList();
			}
		});		
	});
}

function checkAll(t){
	var hasCheck = t.checked;
	$('#equipmentTbl tbody input[type=checkbox]').each(function(){
		if (hasCheck) {
			$(this).prop("checked",true);
		}else{
			$(this).prop("checked",false);
		}
	});
}

function batchDel(){
	var idArr = [];
	$('#equipmentTbl tbody :checked').each(function(){
		idArr.push($(this).next().val());
	});
	if (idArr.length > 0) {
		layer.confirm('确认要删除这'+idArr.length+'条记录吗？',function(index){
			jajax({
				url: '${path}/equipment/delete.do',
				data: 'ids='+idArr.join(','), 
				type: "POST",
				success: function(data, textStatus){
					layer.msg('已删除!',{icon:1,time:1000});
					queryDataList();
				}
			});			
		});
	}else{
		layer.alert('请选择记录!',{icon:1,time:2000});
	}
}

/*设备信息-编辑*/
function equipment_edit(title,url,id,w,h){
	layer.open({
		type: 2,
		area: [w+'px', h +'px'],
		fix: false, //不固定
		maxmin: true,
		shade:0.4,
		title: title,
		content: url,
		success: function(layero, index){
		    var body = layer.getChildFrame('body', index);
		    var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
		    iframeWin.fillData(id);
	    }
	});
}



</script>
</body>
</html>
